//
//  ZRTabBarController.m
//  SinaByOC
//
//  Created by 张锐 on 16/2/27.
//  Copyright © 2016年 zhangr. All rights reserved.
//

#import "ZRTabBarController.h"
#import "ZRHomeViewController.h"
#import "ZRMessageViewController.h"
#import "ZRFindViewController.h"
#import "ZRSettingViewController.h"
#import "ZRTabBar.h"
@interface ZRTabBarController ()<ZRTabBarDelegate>

@end

@implementation ZRTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    //添加子控制器
    [self addChildViewController];
    
    ZRTabBar *myTabBar = [[ZRTabBar alloc]initWithFrame:self.tabBar.bounds];
    
    myTabBar.delegate = self;
    
    [self setValue:myTabBar forKey:@"tabBar"];
    
   
    
}
#pragma mark - ZRTabBarDelegate方法
-(void)compuseButtonClick{

    NSLog(@"点了一下");


}
/**
 *  批量添加所有子控制器
 */
-(void)addChildViewController{
    
    [self addChildViewController:[[ZRHomeViewController alloc]init] andImageName:@"tabbar_home" andTitle:@"首页"];
    [self addChildViewController:[[ZRMessageViewController alloc]init] andImageName:@"tabbar_message_center" andTitle:@"消息"];
    [self addChildViewController:[[ZRFindViewController alloc]init] andImageName:@"tabbar_discover" andTitle:@"发现"];
    [self addChildViewController:[[ZRSettingViewController alloc]init] andImageName:@"tabbar_profile" andTitle:@"设置"];


}
/**
 *  添加子控制器的方法
 */
-(void)addChildViewController:(UIViewController *)childController andImageName:(NSString *)imageName andTitle:(NSString *)title{

    //设置标题
    childController.title = title;
    //设置图片
    childController.tabBarItem.image = [UIImage imageNamed:imageName];
    //设置高亮图片
    childController.tabBarItem.selectedImage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_highlighted",imageName]];
    //添加子控制器
    [self addChildViewController:[[UINavigationController alloc]initWithRootViewController:childController]];

}


@end
